home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
Magazine
/
Online
/
httpproxy
/
src
/
httpproxy.h
< prev
next >
Wrap
C/C++ Source or Header
|
1996-08-20
|
6KB
|
185 lines
/*(( "Header" */
/*
* $Id: httpproxy.h,v 1.10 1996/08/20 17:36:43 mshopf Exp mshopf $
*
* (c) 1995-96 Matthias Hopf
*/
/*
* $Log: httpproxy.h,v $
* Revision 1.10 1996/08/20 17:36:43 mshopf
* changed DEFAULT_DELTIME, added QueueMode, DEFAULT_MIN_REQUESTS.
*
* Revision 1.9 1996/08/12 03:33:36 mshopf
* added Url field in request_t.
*
* Revision 1.8 1996/08/11 22:25:15 mshopf
* reworked debug messages.
*
* Revision 1.7 1996/07/30 13:57:03 mshopf
* reserved the last 256 bytes in the databuffer for error messages.
*
* Revision 1.6 1996/07/17 16:42:42 mshopf
* support for new cache system.
*
* Revision 1.5 1996/06/06 23:01:23 mshopf
* added AlwaysReload
*
* Revision 1.4 1996/06/03 04:08:19 mshopf
* added timeout values.
* added connection error state.
*
* Revision 1.3 1996/04/26 05:14:03 mshopf
* move network encapsulation to net.h
* V0.13 alpha 5 fix.
*
* Revision 1.2 1996/04/24 17:41:16 mshopf
* config changes.
* net handler enhancement.
*
* Revision 1.1 1996/04/24 03:20:13 mshopf
* Initial revision
*
*/
/*)) */
#ifndef _HTTPPROXY_H__
#define _HTTPPROXY_H__
/* not nice - to be reviced */
#include "cache.h"
#include "debug.h"
#include <stdio.h>
#include <dos.h>
#include <dos/datetime.h>
/*(( "Defaults" */
#define DEFAULT_PROXYPORT 8080
#define DEFAULT_TIMEOUT (10*60) /* default: timeout (10 mins) */
#define DEFAULT_DELTIME (710*24*60*60) /* default: delete cached files on startup - two years - httpdelete should do that */
#define DEFAULT_EXPIRETIME (7*24*60*60) /* default: delete cache, when the page is requested and too old */
#define DEFAULT_RELOADTIME 10 /* default: expire cache on reload inbetween */
#define DEFAULT_MAX_REQUESTS 16 /* Maximum number of pending requests */
#define DEFAULT_MIN_REQUESTS 12 /* Minimum number of free requests for interactive actions */
/*)) */
/*(( "Constants" */
#define NAME_CACHETABLE ".cachetable"
#define MIN_REQUESTS 12 /* Minimum number of free requests for interactive actions */
#define MAX_FILENAME 20 /* maximum size of filename (>= 20) */
#define MAX_URLSAVE 128 /* maximum size of saved url requests */
#define MAX_URLBUFFER 512 /* no Url of any request may be larger than this value (<=MAX_REQBUFFER) */
#define MAX_REQBUFFER 1024
#define MAX_DATABUFFER 2048
#define RESERVED_DATABUFFER 256 /* reserved for error messages */
#define SHIFT_DATABUFFER 512 /* when x bytes are in the data buffer, shift it after send() */
#define SHIFT_REQBUFFER 512 /* dto. for the request buffer */
#define MAX_HOSTNAMELEN 64 /* maximum number of characters of the hostname saved */
#ifndef FALSE
#define FALSE (0)
#define TRUE (1)
#endif
/*)) */
/*(( "Flags" */
#define REQ_REQSOCKET 0x01 /* a request socket is open */
#define REQ_CONNSOCKET 0x02 /* a connection socket is open / to be connected */
#define REQ_DONE 0x04 /* the connection socket is already closed */
#define REQ_REQDONE 0x08 /* the URL is completely read (cache may be sent) */
#define REQ_HTTP1X0 0x10 /* the URL was sent with HTTP/1.0 */
#define REQ_URLDONE 0x40 /* the URL request (the first) line is already there */
#define REQ_URLINBUFFER 0x80 /* the valid URL description can be found '\0'-terminated in the
* UrlBuffer entry, not in any cache entry (proxy only mode) */
#define REQ_LOGGED 0x100 /* The request is already logged (error/message information) */
#define REQ_CONNERR 0x200 /* Error while trying to open connection socket */
#define REQ_NEWCACHE 0x400 /* We're writing into a new cachefile */
#define REQ_PENDINGMASK 0x03 /* There is any Connection pending */
/*
* Some typical Flag combinations in typical order:
* None: Empty slot
* REQ_REQSOCKET: Awaiting URL
* REQ_REQSOCKET | REQ_CONNSOCKET: Still geting URL, but 1. line is already there
* *or* URL done
* Awaiting connection to remote host
* *or* already transfering data
* REQ_REQSOCKET | REQ_DONE: The connection socket is already closed, but data is
* still to be delivered, or data is sent from the cache
* REQ_CONNSOCKET: Request was terminated, still geting data to fill up
* the cache.
*/
/* REQ_REQSOCKET: alone will never occour on ProxyProxy==TRUE... */
/*)) */
/*(( "Makros" */
/* Needed Memory */
#define NEED_MEM ((MaxRequests * sizeof (request_t)) / 1024)
#define difftime(x,y) (((u_long)(x)) - ((u_long)(y)))
#define isvalidhttp(x) ((unsigned char)(x) > ' ' && (x) != '%' && (x) != '\\' && (unsigned char)(x) < 128)
/*)) */
/*(( "Types" */
#if 0
typedef struct {
int Flags;
char File [MAX_FILENAME]; /* "" if free slot / with begining '_' (data) */
char Url [MAX_URLSAVE]; /* "" if free slot or just getting data */
} cache_t;
typedef struct cachearray {
struct cachearray *Next;
cache_t Caches [MAX_CACHES];
} cachearray_t;
#endif
typedef struct _request {
int ReqSocket, ConnSocket;
int Flags;
char Address [MAX_HOSTNAMELEN];
char Url [MAX_URLSAVE];
char ReqBuffer [MAX_REQBUFFER];
char UrlBuffer [MAX_URLBUFFER];/* This one contains the URL line for sending the request */
char DataBuffer [MAX_DATABUFFER];
int ReqSent, ReqRecv;
int UrlSent, UrlRecv;
int DataSent, DataRecv;
cachefile_t Cache;
struct DateStamp LastStamp; /* last access time for timeouts */
} request_t;
/*)) */
/*(( "Global Variables" */
extern request_t *Requests;
extern int OffLine;
extern int GetQueued;
extern int AlwaysReload;
extern int QueueMode;
extern struct DateStamp RequestStamp; /* Current time while the request is processed */
/*)) */
extern void ExitAll (int);
extern void CheckGetQueued (int);
extern int ScanService (request_t *, const char *);
extern void ErrToReq (request_t *, int, int, const char *, const char *, const char *);
extern void ShutdownConnects (void);
#endif /* _HTTPPROXY_H__ */